//
//  ContactsHeaderView.m
//  Findif
//
//  Created by Mac on 2019/2/15.
//  Copyright © 2019年 Cicel Chen. All rights reserved.
//

#import "ContactsHeaderView.h"

@interface ContactsHeaderView ()

@property (nonatomic, weak)UIButton * searchButton;

@end

@implementation ContactsHeaderView

- (instancetype)initWithFrame:(CGRect)frame{
    
    if ([super initWithFrame:frame]) {
        
        [self setupUI];
    }
    
    return self;
}


- (void)setupUI{
    
    self.backgroundColor = ZRWhiteColor;
    self.userInteractionEnabled = YES;
    
    UIButton * searchButton = [UIButton new];
    
    [searchButton setImage:[UIImage imageNamed:@"搜索框"] forState:UIControlStateNormal];
    [searchButton addTarget:self action:@selector(didSearchButton) forControlEvents:UIControlEventTouchUpInside];
    
    self.searchButton = searchButton;
    
    [self addSubview:self.searchButton];
}


- (void)layoutSubviews{
    
    [self.searchButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.mas_equalTo(self).offset(15 * SCREENH6);
        make.trailing.mas_equalTo(self).offset(-15 * SCREENH6);
        make.height.mas_equalTo(30 * SCREENH6);
        make.centerY.mas_equalTo(self);
    }];
}


- (void)didSearchButton{
    
    if (self.delegate && [self.delegate respondsToSelector:@selector(clickSearchButton)])
    {
        
        [self.delegate clickSearchButton];
    }
}

@end
